package com.ailink.collection.map;

import com.ailink.collection.map.test.LinkedHashMap;

import java.util.Map;

/**
 * Created by Administrator on 2018/11/19
 */
public class LinkedHashMapTest<K, V> extends LinkedHashMap<K, V> {

    private final int CACHE_SIZE;

    public LinkedHashMapTest(int initialCapacity, float loadFactor, int CACHE_SIZE) {
        super(initialCapacity, loadFactor, true);
        this.CACHE_SIZE = CACHE_SIZE;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
//        return super.removeEldestEntry(eldest);
        return size() > CACHE_SIZE;
    }

    public static void main(String[] args) {
        LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap(8, 0.75f, true);
        linkedHashMap.put("01", "01");
        linkedHashMap.put("02", "03");
        linkedHashMap.put("03", "03");

        linkedHashMap.get("01");
    }
}
